package org.smart4j.system.service;

import org.apache.shiro.crypto.hash.Md5Hash;
import org.smart4j.framework.annotation.Service;
import org.smart4j.framework.helper.DatabaseHelper;
import org.smart4j.framework.util.CodecUtil;
import org.smart4j.system.entity.UserBean;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Wangminze on 2017/3/25.
 * Description:
 */
@Service
public class UserService {

    public UserBean addUser(UserBean user){

        if (user == null){
            return null;
        }

        Map<String,Object> map = new HashMap<String, Object>();
        map.put("username",user.getUsername());
        map.put("password", CodecUtil.md5(user.getPassword()));

        int id = DatabaseHelper.insertEntity(UserBean.class, map);

        System.out.println("id="+id);

        return user;
    }
}
